/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.google.code.jmarias.common.action;

import com.google.code.jmarias.common.AbstractUser;
import com.google.code.jmarias.common.Card;
import com.google.code.jmarias.common.NewTable;
import javax.xml.bind.annotation.XmlRootElement;

/**
 * action that can be used to communicate both ways - first used by client to pick
 * a card number, and, in return, server will send the client the card that has
 * been chosen
 * @author josef
 */
@XmlRootElement
public class PickCardFromPeopleAction extends GameAction {

    private int cardOrder = -1; //poradove cislo karty, ktera byla z lidu vybrana K->S
    private Card pickedCard; //karta, ktera byla vybrana, od S->K

    public PickCardFromPeopleAction() {
    }

    public PickCardFromPeopleAction(int cardOrder) {
        this.cardOrder = cardOrder;
    }

    public PickCardFromPeopleAction(Card pickedCard) {
        this.pickedCard = pickedCard;
    }

    @Override
    public void updateTable(NewTable table, AbstractUser user) {
        table.setTrump(pickedCard);
    }

    @Override
    public String toString() {
        String s = "";
        if (pickedCard != null) {
            s = ", coz je " + pickedCard;
        }

        return "Volim z lidu " + (cardOrder + 1) + ". kartu" + s;
    }

    public Card getPickedCard() {
        return pickedCard;
    }

    public void setPickedCard(Card pickedCard) {
        this.pickedCard = pickedCard;
    }

    public int getCardOrder() {
        return cardOrder;
    }

    public void setCardOrder(int cardOrder) {
        this.cardOrder = cardOrder;
    }
}
